﻿using AiXiu.BLL;
using AiXiu.IBLL;
using AiXiu.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AiXiu.Web
{
    /// <summary>
    /// 视频播放页
    /// </summary>
    public partial class Play : System.Web.UI.Page
    {
        public string VideoId;
        public int UserId;
        public TBVideos Video;
        public TBUsers Author;
        public GetPlayInfoResult playInfo;
        public bool IsLike = false;
        public long LikeCount = 0;
        public long DiscussCount = 0;

        private void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //获取播放视频的视频id
                VideoId = Request.QueryString["id"];
                //获取发布者信息
                IUserManager userManager = new UserManager();
                Video = userManager.GetVideoByVideoId(VideoId);
                Author = Video.TBUsers;
                //获取阿里云视频信息
                playInfo = userManager.InitPlay(VideoId);
                //页面加载后显示当前点赞数量
                TBUsers tBUsers = IdentityManager.ReadUser();
                UserId = tBUsers.Id;
                //点赞
                IsLike = userManager.IsLike(VideoId, UserId);
                LikeCount = userManager.Count(VideoId);
            }
        }
    }
}